package com.d3.sx_eprotection.service.serviceImp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.d3.sx_eprotection.entity.SupervisorMesg;
import com.d3.sx_eprotection.mapper.SupervisorMesgMapper;
import com.d3.sx_eprotection.service.SupervisorMesgService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class SupervisorMesgServiceImp extends ServiceImpl<SupervisorMesgMapper, SupervisorMesg> implements SupervisorMesgService {
    @Resource
    private SupervisorMesgMapper supervisorMesgMapper;


    @Override
    public int addMesg(SupervisorMesg supervisorMesg) {
        return supervisorMesgMapper.insert(supervisorMesg);
    }

    @Override
    public List<SupervisorMesg> findAll(String number) {
        return supervisorMesgMapper.findAll(number);
    }

    @Override
    public List<SupervisorMesg> findBelong(String code) {
        return supervisorMesgMapper.findBelong(code);
    }

    @Override
    public List<SupervisorMesg> findone(int id) {
        return supervisorMesgMapper.findone(id);
    }

    @Override
    public Page<SupervisorMesg> getList(Page<SupervisorMesg> page) {
        return null;
    }

    @Override
    public List<SupervisorMesg> noFyList() {
        return supervisorMesgMapper.getShowList();
    }


    @Override
    public Boolean updateGrider(Integer bindID, String code) {
        return supervisorMesgMapper.updateGrider(bindID,code);
    }

    @Override
    public Boolean updateStatus(int id) {
        return supervisorMesgMapper.updateStatus(id);
    }

    @Override
    public IPage<SupervisorMesg> returnList(Page<SupervisorMesg> page, Map<String, Object> conditionMap) {
        QueryWrapper<SupervisorMesg> queryWrapper = new QueryWrapper<>();
        // 设置查询条件
        if (conditionMap.containsKey("province")) {
            queryWrapper.eq("province", conditionMap.get("province"));
        }
        if (conditionMap.containsKey("city")) {
            queryWrapper.eq("city", conditionMap.get("city"));
        }
        if (conditionMap.containsKey("level")) {
            queryWrapper.eq("level", conditionMap.get("level"));
        }
        if (conditionMap.containsKey("date")) {
            queryWrapper.eq("date", conditionMap.get("date"));
        }
        if (conditionMap.containsKey("status")) {
            queryWrapper.eq("status", conditionMap.get("status"));
        }
        // 执行分页查询
        return supervisorMesgMapper.selectPage(page, queryWrapper);
    }

    @Override
    public List<SupervisorMesg> getFinish() {
        return supervisorMesgMapper.getFinsh();
    }
}
